// part1:C10:ex10.36.cpp
// use find to find last element which value equal to zero from list<int>.
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;

int main(int argc, char *argv[]) {
  list<int> li = {0, 1, 2, 0, 3, 4, 5, 0, 6}; 
  auto last_z = find(li.rbegin(), li.rend(), 0);
  last_z++;
  int idx = 1;

  for (auto iter = li.begin(); iter != last_z.base();iter++, idx++) {
  }

  if (idx >= li.size()) {
    cout << "container not include zero." << endl;
  } else {
    cout << "last zero at : " << idx << endl;
  }
  return 0;
}

